/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */
package servlet;

import javax.servlet.ServletContext;
import javax.servlet.ServletContextEvent;
import javax.servlet.ServletContextListener;
import javax.servlet.annotation.WebListener;
import org.springframework.context.ApplicationContext;
import org.springframework.context.support.ClassPathXmlApplicationContext;

/**
 * Web application lifecycle listener.
 *
 * @author Administrador
 */
@WebListener()
public class Listener implements ServletContextListener {

    @Override
    public void contextInitialized(ServletContextEvent sce) {
        
        ApplicationContext aplicacion = new ClassPathXmlApplicationContext("basedatos3.xml");
        ServletContext application = sce.getServletContext();
        
        application.setAttribute("contextoSpring", aplicacion);
        
        application.setAttribute("DAO", aplicacion.getBean("proyectoDAO"));
        
    }

    @Override
    public void contextDestroyed(ServletContextEvent sce) {
        
    }
}
